home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / filesy~1 / mfs6011s.zoo / fsck / fs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-31  |  5.3 KB  |  145 lines

  1. /* This is a barebones file that defines the structures of the fs
  2.  * along with a few constants
  3.  */
  4.  
  5. #ifndef NULL
  6. #define NULL 0L
  7. #endif
  8.  
  9.  
  10. #ifdef V1
  11. #define d_inode d_inode1
  12. #define NINDIR 512              /* Zones per indirection block */
  13. #define NDIR   7                /* Direct zones in inode */
  14. #define MAGIC SUPER_V1          /* Super block magic number */
  15. #define MAGIC_ALT SUPER_V2
  16. #define NR_ZONE    NR_ZONE1
  17. typedef unsigned short zone_nr;
  18. #define do_fsck do_fsck1
  19. #define FS_TYPE "V1"
  20. #else
  21.  
  22. #ifdef V2
  23. #define d_inode d_inode2
  24. #define NINDIR 256
  25. #define NDIR    7
  26. #define MAGIC SUPER_V2
  27. #define MAGIC_ALT SUPER_V1
  28. #define NR_ZONE NR_ZONE2
  29. typedef long zone_nr;
  30. #define do_fsck do_fsck2
  31. #define FS_TYPE "V2"
  32.  
  33. #endif
  34. #endif
  35.  
  36. #define IPB    (BLOCKSIZE/sizeof(d_inode))    /* Inodes per block */
  37. #define DSIZE (sizeof(dir_struct))        /* Directory entry size */
  38. #define DPB (BLOCKSIZE/DSIZE)            /* Entries per block */
  39.  
  40.  
  41. /* Useful macro , is non zero only if 'x' is not a power of two */
  42.  
  43. #define NPOW2(x) ( ( (x) & (x-1) )!=0)
  44.  
  45. /* Macro to determine maximum filename length for a given increment */
  46.  
  47. #define MMAX_FNAME(x) ( ( (x)<<4 ) -2)
  48.  
  49. /* Absolute maximum filename length */
  50.  
  51. #define MNAME_MAX MMAX_FNAME(MAX_INCREMENT)
  52.  
  53. #define BLOCKSIZE    1024l    /* # bytes in a disk block */
  54.  
  55. /* Flag bits for i_mode in the inode. */
  56.  
  57. #define I_OLDLINK    0160000    /* Old Minixfs symlink mode */
  58.  
  59. #define I_SYMLINK    0120000 /* linux compatible symlink */
  60.  
  61. #define I_TYPE        0170000    /* this field gives inode type */
  62. #define I_REGULAR    0100000    /* regular file, not dir or special */
  63. #define I_BLOCK_SPECIAL 0060000    /* block special file */
  64. #define I_DIRECTORY    0040000    /* file is a directory */
  65. #define I_CHAR_SPECIAL    0020000    /* character special file */
  66. #define I_NAMED_PIPE    0010000 /* named pipe (FIFO) */
  67. #define I_SET_UID_BIT    0004000    /* set effective uid_t on exec */
  68. #define I_SET_GID_BIT    0002000    /* set effective gid_t on exec */
  69. #define I_STICKY    0001000 /* sticky bit */
  70. #define ALL_MODES    0007777    /* all bits for user, group and others */
  71. #define RWX_MODES    0000777    /* mode bits for RWX only */
  72. #define R_BIT        0000004    /* Rwx protection bit */
  73. #define W_BIT        0000002    /* rWx protection bit */
  74. #define X_BIT        0000001    /* rwX protection bit */
  75. #define I_NOT_ALLOC    0000000    /* this inode is free */
  76.  
  77. /* Miscellaneous constants */
  78. #define SUPER_V1   0x137F    /* magic number contained in super-block */
  79. #define SUPER_V1_30 0x138f    /* magic number for v1+30 characters (Linux) */
  80. #define SUPER_V2   0x2468    /* v2 magic number */
  81.  
  82. #define NR_ZONE1 9
  83. #define NR_ZONE2 10
  84.  
  85. /* Macros for zone counts */
  86.  
  87. #define    NO_IND(x)    (((x)-NDIR+NINDIR-1)/NINDIR)
  88. #define NO_DBL(x)    (((x) - NDIR - NINDIR + (long)NINDIR*NINDIR - 1) \
  89.              / ((long)NINDIR*NINDIR))
  90. #define NO_TRPL(x)    ((x) > NDIR + NINDIR + (long)NINDIR*NINDIR ? 1 : 0)
  91.  
  92. #define ROOT_INODE  1    /* inode number for root directory */
  93.  
  94.  
  95. typedef struct    {
  96.   unsigned short s_ninodes;        /* # usable inodes on the minor device */
  97.   unsigned short s_nzones;        /* total device size, including bit maps etc */
  98.   unsigned short s_imap_blks;        /* # of blocks used by inode bit map */
  99.   unsigned short s_zmap_blks;        /* # of blocks used by zone bit map */
  100.   unsigned short s_firstdatazn;    /* number of first data zone */
  101.   short int s_log_zsize;    /* log2 of blocks/zone */
  102.   long  s_max_size;        /* maximum file size on this device */
  103.   short s_magic;        /* magic number to recognize super-blocks */
  104.   short pad;            /* padding */
  105.   long s_zones;            /* long version of s_nzones for v2 */
  106. } super_block;
  107.  
  108. /* This is what a directory entry on the disk looks like. Note: we can use
  109.  * a dirty trick to use this same structure for large filenames > 14 chars
  110.  * the idea is to use only a fraction of the total entries , so that if
  111.  * say the filename size is 30 we just use entries 0,2,4,6,8 etc. d_name
  112.  * then occupies all of the next entry. This forces the max filename size
  113.  * to be 2 less than a power of two (and certainly less than 1022), normally
  114.  * 30 should be more than adequate to cover every filename you'll ever see.
  115.  * 62 is for paranoids , but remember the path name limit of 128 characters.
  116.  */
  117.  
  118. typedef struct {        /* directory entry */
  119.   unsigned short d_inum;    /* inode number */
  120.   char d_name[14];        /* character string */
  121. } dir_struct;
  122.  
  123. typedef struct {        /* disk inode. */
  124.   unsigned short i_mode;        /* file type, protection, etc. */
  125.   unsigned short i_uid;            /* user id of the file's owner */
  126.   long i_size;            /* current file size in bytes */
  127.   long i_mtime;        /* when was file data last changed */
  128.   unsigned char i_gid;            /* group number */
  129.   unsigned char i_nlinks;        /* how many links to this file */
  130.   unsigned short i_zone[NR_ZONE1];    /* block nums for direct, ind, and dbl ind */
  131. } d_inode1;
  132.  
  133. typedef struct {        /* V2.x disk inode */
  134.   unsigned short i_mode;        /* file type, protection, etc. */
  135.   unsigned short i_nlinks;        /* how many links to this file. HACK! */
  136.   unsigned short i_uid;            /* user id of the file's owner. */
  137.   unsigned short i_gid;            /* group number HACK! */
  138.   long i_size;        /* current file size in bytes */
  139.   long i_atime;        /* when was file data last accessed */
  140.   long i_mtime;        /* when was file data last changed */
  141.   long i_ctime;        /* when was inode data last changed */
  142.   long i_zone[NR_ZONE2];    /* block nums for direct, ind, and dbl ind */
  143. } d_inode2;
  144.  
  145.